<?php

$name = $_POST['name'];
$pwd = $_POST['pwd'];

if (valide_user($name, $pwd)) {
	echo 1;
	//登陆成功
} else {
	echo 0;
	//登陆失败
}

function valide_user($user_name, $password) {
	$value = FALSE;
	$conn = @mysql_connect("127.0.0.1:3306", "root", "") or die("链接错误");
	mysql_select_db("dingshi", $conn);
	$result = mysql_query("SELECT * FROM `user` where `name`='$user_name' and `password`='$password'", $conn);

	if (mysql_num_rows($result) > 0) {
		$value = TRUE;
	} else {
		$value = FALSE;
	}
	// 释放资源
	mysql_free_result($result);
	// 关闭连接
	mysql_close($conn);
	return $value;
}
?>